#ifndef EVENT_QUEUE_HPP_
#define EVENT_QUEUE_HPP_

#include <functional>
#include <mutex>
#include <list>

namespace event_framework
{
    template <typename Command>
    class CommandQueue final
    {
    public:
        CommandQueue() = default;
        ~CommandQueue() = default;
        void Accept(Command&& cmd)
        {
            std::lock_guard<std::mutex> lck(mtx);
            cmdList.emplace_back(std::move(cmd));
        }
        void Take(std::list<Command>& lst)
        {
            std::lock_guard<std::mutex> lck(mtx);
            lst.swap(cmdList);
        }
    private:
        std::list<Command> cmdList;
        std::mutex mtx;
    };
}
#endif